//
//  SingleLineTextField.m
//  CustomView
//
//  Created by hoho on 14-11-13.
//  Copyright (c) 2014年 thinkcart.net. All rights reserved.
//

#import "SingleLineTextField.h"

@implementation SingleLineTextField {
    CALayer *bottomBorder;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

-(void)setBounds:(CGRect)newBounds {
    [super setBounds:newBounds];
    //比如说转为横屏，textField也跟着变长，那么这个border应该也跟着变长。
    if(bottomBorder){
        bottomBorder.frame = CGRectMake(0.0f, self.frame.size.height - _borderWidth, self.frame.size.width, _borderWidth);
    }
}

- (void)drawRect:(CGRect)rect {
    
    bottomBorder = [CALayer layer];
    bottomBorder.frame = CGRectMake(0.0f, self.frame.size.height - _borderWidth, self.frame.size.width, _borderWidth);
    bottomBorder.backgroundColor = _borderColor.CGColor;
    [self.layer addSublayer:bottomBorder];
}

@end
